#ifndef SQLUTIL_H
#define SQLUTIL_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include "contactinfo.h"
class SqlUtil : public QObject
{
    Q_OBJECT
public:
    explicit SqlUtil(QObject *parent = nullptr);
    void initSqlLite();
    QSqlDatabase db;
    QSqlQuery *psql;
    QSqlQuery* selectDb(QString tableName);
    void insertDb(QString tableName,QList<QString> *bindKeyList,QList<QString> *bindValList);
    void updateDb(QString tableName,QList<QString> *bindValList);
    void deleteDb(QString tableName,QList<QString> *bindValList);
    void addContact(ContactInfo *contactinfo);
    void addMsg(ContactInfo *contactinfo);
    QList<ContactInfo*>*  contactList();
    bool contactListByMacAddr(ContactInfo *contactinfo);
    QList<ContactInfo*>*  talkRecordListByContactMac(ContactInfo *contactinfo);
    void openDb();
signals:
    void initSuccess();
};

#endif // SQLUTIL_H
